package com.tts.controller;

import com.tts.dto.ApiResponse;
import com.tts.dto.BorrowStatisticsDTO;
import com.tts.dto.CategoryStatisticsDTO;
import com.tts.dto.PopularBookDTO;
import com.tts.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @GetMapping("/borrow")
    public ApiResponse<BorrowStatisticsDTO> getBorrowStatistics(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate) {
        return ApiResponse.success(statisticsService.getBorrowStatistics(startDate, endDate));
    }

    @GetMapping("/category")
    public ApiResponse<List<CategoryStatisticsDTO>> getCategoryStatistics() {
        return ApiResponse.success(statisticsService.getCategoryStatistics());
    }

    @GetMapping("/popular-books")
    public ApiResponse<List<PopularBookDTO>> getPopularBooks() {
        return ApiResponse.success(statisticsService.getPopularBooks());
    }
} 